"""
键盘的操作:

键盘的执行方法就是 send_keys


"""
import time

from selenium import webdriver
from selenium.webdriver import Keys

from selenium.webdriver.common.by import By

# 1. 先创建浏览器驱动对象
driver=webdriver.Chrome()
# 2 通过get方法打开页面
driver.get("http://localhost:8081/regA.html")

ele_username=driver.find_element(By.CSS_SELECTOR,"#userA")
ele_username.send_keys("admin1")

time.sleep(2)
ele_username.send_keys(Keys.BACKSPACE)
ele_username.send_keys(Keys.CONTROL,"a")

time.sleep(2)
ele_username.send_keys(Keys.CONTROL,"c")
ele_password=driver.find_element(By.CSS_SELECTOR,"#passwordA")
ele_password.send_keys(Keys.CONTROL,"v")

ele_password_value=ele_password.get_attribute("value") #获取输入框的值
if  ele_password_value=="admin":
    print("测试通过")
else:
    print("测试失败")


time.sleep(10)

# 4. 关闭浏览器驱动对象
driver.quit()